numNodesExpAH4 = [40,
 62,
 15,
 33,
 61,
 151,
 29,
 19,
 35,
 25,
 68,
 68,
 96,
 96,
 33,
 65,
 79,
 103,
 100,
 40,
 409,
 58,
 112,
 165,
 661,
 339,
 465,
 13,
 190,
 483,
 152,
 140,
 127,
 53,
 183,
 35,
 230,
 230,
 694,
 96,
 3384,
 95,
 75,
 1433,
 1051,
 129,
 252,
 302,
 1248,
 1521,
 218,
 139,
 448,
 168,
 1903,
 1158,
 233,
 150,
 427,
 223,
 1224,
 363,
 3952,
 299,
 556,
 1387,
 2326,
 2731,
 3532,
 10180,
 1249,
 1777,
 347,
 2584,
 404,
 894,
 2193,
 4861,
 5254,
 483,
 2130,
 17431,
 169,
 10808,
 24671,
 2638,
 5774,
 11622,
 69,
 5225,
 4513,
 287,
 3067,
 9713,
 3177,
 10205,
 23375,
 5262,
 562,
 5124,
 143131,
 44503,
 35860,
 82479,
 15830,
 3736,
 69099,
 53223,
 25520,
 33459,
 8955,
 131166,
 69609,
 25670,
 9871,
 41515,
 1137,
 31133,
 3329,
 1974,
 26990,
 83480,
 282318,
 664868,
 8313,
 23042,
 26616,
 86100,
 287240,
 5968,
 15592,
 51079,
 16646,
 91008,
 111321,
 520719,
 146974,
 92162,
 4745,
 824257]

numNodesExpAH6 = [40,
 27,
 15,
 36,
 27,
 41,
 31,
 29,
 49,
 23,
 57,
 64,
 39,
 68,
 33,
 77,
 77,
 39,
 66,
 48,
 53,
 27,
 81,
 39,
 155,
 92,
 146,
 13,
 69,
 142,
 186,
 114,
 41,
 47,
 98,
 35,
 51,
 51,
 41,
 80,
 198,
 61,
 97,
 257,
 79,
 97,
 291,
 204,
 162,
 122,
 108,
 75,
 433,
 88,
 274,
 51,
 234,
 338,
 248,
 230,
 95,
 140,
 416,
 347,
 580,
 590,
 369,
 277,
 219,
 79,
 163,
 1635,
 79,
 241,
 268,
 157,
 216,
 265,
 277,
 67,
 424,
 1110,
 103,
 1381,
 3549,
 109,
 527,
 1722,
 77,
 929,
 506,
 85,
 746,
 207,
 309,
 197,
 258,
 2110,
 134,
 548,
 629,
 99,
 1401,
 312,
 797,
 149,
 585,
 782,
 174,
 160,
 458,
 3373,
 466,
 337,
 1191,
 402,
 410,
 349,
 985,
 1010,
 2432,
 4155,
 17550,
 9884,
 103,
 5489,
 299,
 1637,
 5232,
 3397,
 454,
 10028,
 3832,
 366,
 1602,
 13322,
 3297,
 1026,
 1406,
 6536]

numNodesExpRH5 = [1453,
 715,
 119,
 469,
 1049,
 3251,
 409,
 133,
 569,
 127,
 1655,
 2713,
 1059,
 4501,
 405,
 1863,
 1339,
 2203,
 2533,
 555,
 1323,
 1105,
 12391,
 2729,
 102057,
 2951,
 16261,
 119,
 1347,
 13099,
 625,
 4987,
 1397,
 563,
 6827,
 227,
 3227,
 4419,
 599,
 2785,
 122669,
 979,
 5509,
 439953,
 12197,
 759,
 83665,
 28663,
 108869,
 28165,
 847,
 133,
 208383,
 4973,
 46539,
 3795,
 11097,
 2993,
 12407,
 76401,
 15809,
 6567,
 138305,
 275429,
 70821,
 140011,
 20079,
 6587,
 31299,
 30597,
 144659,
 886217,
 49281,
 5621,
 8727,
 8671,
 195779,
 341789,
 153759,
 739,
 180943,
 1044989,
 19625,
 114181,
 111767,
 35217,
 51867,
 564257,
 359,
 2086199,
 1593863,
 194071,
 1470783,
 6230545,
 689911,
 21877,
 1611635,
 42000003,
 1021519,
 2027345,
 42000003,
 6910371,
 42000001,
 1860017,
 1927719,
 404463,
 19659747,
 35958361,
 9917,
 21277047,
 1086207,
 42000003,
 327129,
 658373,
 611829,
 42000001,
 90167,
 2066521,
 411365,
 148199,
 10630839,
 42000005,
 42000003,
 42000001,
 42000001,
 42000001,
 430311,
 8520317,
 42000003,
 46513,
 42000003,
 42000003,
 42000005,
 42000003,
 42000001,
 42000003,
 42000001,
 42000003,
 42000005,
 42000001]

numNodesExpRH8 = [3171,
 225,
 119,
 305,
 301,
 181,
 409,
 127,
 397,
 113,
 6325,
 4785,
 1011,
 2155,
 417,
 709,
 1009,
 195,
 2425,
 511,
 601,
 317,
 78749,
 155,
 6273,
 337,
 765,
 119,
 161,
 89495,
 325,
 27433,
 205,
 467,
 359,
 197,
 277,
 789,
 201,
 4801,
 2587,
 677,
 321,
 9775,
 4287,
 1269,
 642433,
 117751,
 24879,
 839,
 615,
 219,
 2197165,
 2199,
 2513,
 487,
 18523,
 463,
 16103,
 715349,
 477,
 3053,
 29297,
 4995,
 150215,
 4697,
 1325,
 451,
 897,
 547,
 8303,
 228179,
 575,
 591,
 285,
 12667,
 5209,
 3189,
 3661,
 305,
 1773,
 3486947,
 9449,
 1307,
 177245,
 895,
 2875,
 79509,
 255,
 256303,
 10391,
 555,
 909,
 3737,
 3579,
 1799,
 14591,
 229843,
 779,
 5919,
 1413561,
 1843,
 13653,
 4685,
 32845,
 35545,
 194825,
 35823,
 6389,
 10745,
 189283,
 128383,
 981,
 251789,
 2737,
 25977,
 697,
 24365,
 84783,
 36407,
 31683,
 169259,
 3673673,
 3239047,
 457597,
 446099,
 79041,
 101925,
 1716477,
 7961,
 4689,
 1184513,
 16121547,
 952921,
 7013,
 61973,
 91083,
 864199,
 266739,
 2841119]

numNodesExpAH7 = [114,
 31,
 15,
 46,
 71,
 194,
 36,
 36,
 53,
 52,
 153,
 19,
 113,
 92,
 99,
 31,
 35,
 94,
 27,
 21,
 599,
 75,
 271,
 107,
 591,
 680,
 726,
 13,
 777,
 549,
 748,
 517,
 382,
 303,
 787,
 723,
 228,
 429,
 278,
 39,
 4737,
 1335,
 2811,
 2060,
 1183,
 63,
 888,
 2645,
 4027,
 2653,
 1179,
 2247,
 275,
 325,
 601,
 2971,
 1109,
 1027,
 3840,
 2519,
 1956,
 10676,
 4249,
 5148,
 6371,
 1972,
 8580,
 28834,
 7166,
 2960,
 17577,
 12044,
 10306,
 14776,
 8699,
 1869,
 11597,
 4177,
 20774,
 14228,
 37033,
 40760,
 75271,
 128260,
 81155,
 74463,
 48953,
 87101,
 5546,
 16586,
 101730,
 43139,
 64257,
 135802,
 163906,
 11598,
 33324,
 69425,
 5362,
 78454]

numNodesExpRH9 = [2297,
 183,
 227,
 2819,
 11497,
 8983,
 2885,
 3915,
 421,
 127,
 1329,
 159,
 4207,
 1361,
 107,
 283,
 215,
 2505,
 477,
 75,
 24651,
 11561,
 5259,
 559,
 31913,
 6105,
 40425,
 227,
 8577,
 2805,
 24153,
 14949,
 9823,
 8477,
 47391,
 58023,
 3449,
 728865,
 13211,
 181,
 1477317,
 3188049,
 324349,
 100455,
 26475,
 759,
 11633,
 453039,
 90315,
 181019,
 339,
 135979,
 2275,
 227637,
 10111,
 382163,
 119,
 459,
 1138289,
 37315,
 4665,
 42000003,
 279153,
 50609,
 105021,
 127443,
 2008563,
 237029,
 601437,
 93505,
 8684829,
 214075,
 382617,
 389767,
 1981593,
 92641,
 42000003,
 19065,
 42000003,
 475163,
 4392025,
 577515,
 42000001,
 42000003,
 5045747,
 19942885,
 42000001,
 42000001,
 42000001,
 2000373,
 2374625,
 42000001,
 42000001,
 42000003,
 42000003,
 42000001,
 40408729,
 3973279,
 1123157,
 27368257]

#-------------------------------------------------------------------------------

import pylab

#for i in range(7):
#    t = -pylab.randint(1,13)
#    numNodesExpAH7.append(numNodesExpAH7[t] + pylab.randint(1,100000))

anodeAH4H = [0]*7
anodeAH6H = [0]*7
anodeAH7H = [0]*5

anodeRH5H = [0]*7
anodeRH8H = [0]*7
anodeRH9H = [0]*5

c = 0
for i in range(0,140,20):
    anodeAH4H[c] = sum(numNodesExpAH4[i:i+20]) / 20.0
    anodeAH6H[c] = sum(numNodesExpAH6[i:i+20]) / 20.0
    anodeRH5H[c] = sum(numNodesExpRH5[i:i+20]) / 20.0
    anodeRH8H[c] = sum(numNodesExpRH8[i:i+20]) / 20.0
    c = c + 1

c = 0
for i in range(0,100,20):
    anodeAH7H[c] = sum(numNodesExpAH7[i:i+20]) / 20.0
    anodeRH9H[c] = sum(numNodesExpRH9[i:i+20]) / 20.0
    c = c + 1




pylab.figure(101)
pylab.plot(range(4,9), anodeAH7H, 'r-', linewidth = 3.5, label = "heuristic 1")
pylab.plot(range(4,11), anodeAH4H, 'b--', linewidth = 3.5, label = "heuristic 2")
pylab.plot(range(4,11), anodeAH6H, 'g-.', linewidth = 3.5, label = "heuristic 3")
pylab.xlabel('number of disks')
pylab.ylabel('number of nodes')
pylab.legend(loc='upper left')
pylab.title('average nodes expanded of A* search')


pylab.figure(102)
pylab.plot(range(4,9), anodeRH9H, 'r-', linewidth = 3.5, label = "heuristic 1")
pylab.plot(range(4,11), anodeRH5H, 'b--', linewidth = 3.5, label = "heuristic 2")
pylab.plot(range(4,11), anodeRH8H, 'g-.', linewidth = 3.5, label = "heuristic 3")
pylab.xlabel('number of disks')
pylab.ylabel('number of nodes')
pylab.legend(loc='upper left')
pylab.title('average nodes expanded of RBFS search')


pylab.figure(103)
pylab.plot(range(1,101), numNodesExpAH7, 'ms', linewidth = 3.5, label = "heuristic 1")
pylab.plot(range(1,141), numNodesExpAH4, 'go', linewidth = 3.5, label = "heuristic 2")
pylab.plot(range(1,141), numNodesExpAH6, 'y^', linewidth = 3.5, label = "heuristic 3")
pylab.xlabel('index of experiments')
pylab.ylabel('number of nodes')
pylab.legend(loc='upper left')
pylab.title('nodes expanded of A* search')

pylab.figure(104)
pylab.plot(range(1,101), numNodesExpRH9, 'gs', linewidth = 3.5, label = "heuristic 1")
pylab.plot(range(1,141), numNodesExpRH5, 'ro', linewidth = 3.5, label = "heuristic 2")
pylab.plot(range(1,141), numNodesExpRH8, 'b^', linewidth = 3.5, label = "heuristic 3")
pylab.xlabel('index of experiments')
pylab.ylabel('number of nodes')
pylab.legend(loc='upper left')
pylab.title('nodes expanded of RBFS search')

#pylab.figure(107)
#pylab.plot(range(4,9), anodeAH7H, 'r-', linewidth = 3.5, dash_joinstyle = 'round', label = 'A*')
#pylab.plot(range(4,9), anodeRH9H, 'b--', linewidth = 3.5, dash_joinstyle = 'round', label = 'RBFS')
##pylab.xlabel('index of experiments')
#pylab.xlabel('number of disks')
#pylab.ylabel('number of expanded nodes')
#pylab.legend(loc='upper left')
#pylab.title('A* v.s. RBFS search (node expanded) heuristic 1')
#
#pylab.figure(105)
#pylab.plot(range(4,11), anodeAH4H, 'r-', linewidth = 3.5, dash_joinstyle = 'round', label = 'A*')
#pylab.plot(range(4,11), anodeRH5H, 'b--', linewidth = 3.5, dash_joinstyle = 'round', label = 'RBFS')
##pylab.xlabel('index of experiments')
#pylab.xlabel('number of disks')
#pylab.ylabel('number of expanded nodes')
#pylab.legend(loc='upper left')
#pylab.title('A* v.s. RBFS search (node expanded) heuristic 2')
#
#pylab.figure(106)
#pylab.plot(range(4,11), anodeAH6H, 'r-', linewidth = 3.5, dash_joinstyle = 'round', label = 'A*')
#pylab.plot(range(4,11), anodeRH8H, 'b--', linewidth = 3.5, dash_joinstyle = 'round', label = 'RBFS')
##pylab.xlabel('index of experiments')
#pylab.xlabel('number of disks')
#pylab.ylabel('number of expanded nodes')
#pylab.legend(loc='upper left')
#pylab.title('A* v.s. RBFS search (node expanded) heuristic 3')


pylab.show()
